﻿
Partial Class DetailKhachSanSale
    Inherits System.Web.UI.Page
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Session("IDCity") Is Nothing Or Request.QueryString("IDKS") Is Nothing Then
            Response.Redirect("~/index.aspx")
        End If
        If Not IsPostBack Then
            'DetailKhachSan.aspx?IDKS={0}
            Dim khachSan As KhachSan = Nothing
            If Request.QueryString("IDKS") IsNot Nothing Then
                Dim idKS As New Guid(Request.QueryString("IDKS"))
                khachSan = KhachSanServer.GetKhachSanByIDKhachSan(idKS)
                'Dim strCity As String = KhachSanServer.GetCityNameByIDCity(khachSan.CITY_ID)

                'Dim arrivalDate As Date = Session("ArrivalDate")
                'Dim departureDate As Date = Session("DepartureDate")
                'Dim nDays As Long = DateDiff("d", arrivalDate, departureDate)
                'Dim _Date As Date = DateAdd(DateInterval.Day, +1, Now.Date)
                'Dim strDayWeek As String = String.Format("{0} {1}", Util.GetStrThuTrongTuan(arrivalDate.DayOfWeek), Format("MM/dd/yyyy", arrivalDate))
                'Dim lstItem As New ListItem(nDays, arrivalDate)

                divNameHotel.InnerHtml = khachSan.NAME
                lnkQuayLai.Text = "Khách Sạn tại " + Session("NameCity")
                Dim strURLQuayLai As String = String.Format("~/SearchKhachSan.aspx?ArrivalDate={0}&DepartureDate={1}&CityID={2}&Guests={3}&Rooms={4}", Session("ArrivalDate"), Session("DepartureDate"), Session("IDCity"), Session("Guests"), Session("Rooms"))
                lnkQuayLai.PostBackUrl = strURLQuayLai

                divKhuyenMai.InnerHtml = ""
                Dim listKhuyenMai As List(Of KhuyenMaiTheoHotel) = KhuyenMaiTheoHotelServer.GetListKhuyenMaiByIDHotel(idKS)
                For i As Integer = 0 To listKhuyenMai.Count - 1
                    Dim strHTML As String = " <div class='bottom-40' style='border-top: 1px solid #ccc; padding-top: 40px;'>"
                    strHTML &= " <div class='bottom-5 green' style='font-size: 1.2em;'>"
                    strHTML &= " <b><a href='#'>" + listKhuyenMai(i).NAME_KM + "</a></b>"
                    strHTML &= " </div>"
                    strHTML &= " <div class='top-10 bottom-20 small' style='color: #777;'>"
                    strHTML &= "  Thời hạn chương trình khuyến mãi<br />"
                    strHTML &= "  Ngày bắt đầu: " + listKhuyenMai(i).NGAY_BAT_DAU + "<br />"
                    strHTML &= " Ngày kết thúc: " + listKhuyenMai(i).NGAY_KET_THUC + "</div>"
                    strHTML &= " <div class='rate' style='padding:2px 5px 0 0;font-weight:normal;'>Giá trọn gói <span style='margin-left:10px;font-weight:bold;'>" + Format(listKhuyenMai(i).GIA_RE, "#,###") + "</span></div>"
                    strHTML &= " <div class='top-20 bottom-10' style='margin-left:-5px;'>"
                    Dim strURL As String = String.Format("DetailKhachSanPut.aspx?IDKS={0}&IDKM={1}", Request.QueryString("IDKS"), listKhuyenMai(i).IDKHUYENMAI)
                    strHTML &= " <a href='" + strURL + "'"
                    strHTML &= " data-role='button' data-inline='true' data-theme='b' data-ajax='false'>Đặt Khuyến"
                    strHTML &= "  Mãi</a>"
                    strHTML &= "  </div>"
                    strHTML &= " <div class='bottom-5'>" + listKhuyenMai(i).NOI_DUNG
                    strHTML &= " <br><br>Phụ thu:<br>" + listKhuyenMai(i).PHU_THU + "<br>Lưu ý: <br>" + listKhuyenMai(i).LUU_Y + "<br><br /></div>"
                    strHTML &= " </div>"
                    divKhuyenMai.InnerHtml = divKhuyenMai.InnerHtml + strHTML
                Next
                Dim listLoaiPhong As List(Of KhachSan) = KhachSanServer.GetLoaiHotelByIdHotel(idKS)
                lnkDatPhong.PostBackUrl = String.Format("~/DetailKhachSanPut.aspx?IDKS={0}&IDLP={1}", Request.QueryString("IDKS"), listLoaiPhong(0).IDLOAIPHONG)


            End If
            'Dim strPathAndQuery As String = HttpContext.Current.Request.Url.PathAndQuery
            'Dim strUrl As String = HttpContext.Current.Request.Url.AbsoluteUri.Replace(strPathAndQuery, "")
            'strUrl = strUrl & khachSan.LINK
        End If
    End Sub

    
End Class
